﻿Public Class Cells : Inherits SortedList(Of Integer, Cell)

	Dim Sheet As Sheet

	Sub New(Parent As Sheet)
		Sheet = Parent
	End Sub

	Default Shadows Property Item(x As Integer, y As Integer) As Cell
		Get
			If x < 0 Or y < 0 Then Stop
			If Not ContainsKey(y * 256 + x) Then
				Add(y * 256 + x, New Cell(Sheet, x, y))
			End If
			Return MyBase.Item(y * 256 + x)
		End Get
		Set(value As Cell)
			If Not ContainsKey(y * 256 + x) Then
				Add(y * 256 + x, New Cell(Sheet, x, y))
			End If
			MyBase.Item(y * 256 + x) = value
		End Set
	End Property

	Sub Paint(e As PaintEventArgs, R As Rectangle, x As Integer, y As Integer, Forecolor As Color, Bold As String, Italic As String)
		If Not ContainsKey(y * 256 + x) Then Return
		Dim Cell = MyBase.Item(y * 256 + x)
		Cell.Paint(e, R, Forecolor, Bold, Italic)
	End Sub

End Class